package cn.jn.lhm.part01;

import java.nio.ByteBuffer;

/**
 * @author lhm 2753914576@qq.com
 * @time 2022/6/19 - 23:44
 **/
public class ByteBufferReadWrite {
    public static void main(String[] args) {
        ByteBuffer buffer = ByteBuffer.allocate(10);
        buffer.put((byte) 0x61); // 'a'
        ByteBufferUtil.debugAll(buffer);
        buffer.put(new byte[]{0x62, 0x63, 0x64}); // b c d
        ByteBufferUtil.debugAll(buffer);


        buffer.flip();
        System.out.println(buffer.get());
        ByteBufferUtil.debugAll(buffer);

        buffer.compact();
        ByteBufferUtil.debugAll(buffer);

        buffer.put(new byte[]{0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b}); // e f
        ByteBufferUtil.debugAll(buffer);
    }
}
